<!--
 * @Description: 检测数据查询
 * @Autor: xiej
 * @Date: 2020-08-27 11:46:17
 * @LastEditors: xiej
 * @LastEditTime: 2020-08-28 13:37:11
-->h
<template>
  <div class="app-content h-flex">
    <div class="datas-left">
      <p class="datas-left-p">检测方式</p>
      <ul class="datas-left-p-qh">
        <li><a :class="{active: currentAnalysis === 'A4C'}" @click="changeCurrentAnalysis('A4C')">4c</a></li>
        <li><a :class="{active: currentAnalysis === 'A2C'}" @click="changeCurrentAnalysis('A2C')">2c</a></li>
        <li><a :class="{active: currentAnalysis === 'A1C'}" @click="changeCurrentAnalysis('A1C')">1c</a></li>
        <!-- <li><a :class="{active: currentAnalysis === 'A3C'}" @click="changeCurrentAnalysis('A3C')">3c</a></li> -->
        <!-- <li><a :class="{active: currentAnalysis === 'A5C'}" @click="changeCurrentAnalysis('A5C')">5c</a></li> -->
      </ul>
    </div>
    <div class="datas-cent h-flex-elastic">
      <keep-alive>
        <component :is="currentAnalysis" :line-code="lineCode" style="height: 100%;" @find-detect-data="findDetectData" />
      </keep-alive>
    </div>
  </div>
</template>

<script>
import A1C from './components/A1c'
import A2C from './components/A2c'
import A3C from './components/A3c'
import A4C from './components/A4c'
import A5C from './components/A5c'
import {
  find1cDetectData,
  find2cDetectData,
  find3cDetectData,
  find4cDetectData,
  find5cDetectData } from '@/api/cms/detect-data'
export default {
  name: 'DetectData',
  components: {
    A1C,
    A2C,
    A3C,
    A4C,
    A5C
  },
  props: {
    tophie: {
      type: String,
      default: 'true'
    },
    hideHeader: {
      type: Boolean,
      default: false
    },
    param: {
      type: Object
    }
  },
  data() {
    return {
      currentAnalysis: 'A4C',
      tableDataDefect: {},
      lineCode: ''
    }
  },
  watch: {
    param(val) {
      if (val) {
        const queryParams = {}
        queryParams.lineCode = val.lineCode
        this.lineCode = val.lineCode
        this.currentAnalysis = val.ctype
        this.findDetectData(queryParams)
      }
    }
  },
  mounted() {
    const queryParams = {}
    this.find1cDetectData(queryParams)
  },
  methods: {
    changeCurrentAnalysis(val) {
      this.currentAnalysis = val
    },
    findDetectData(queryParams) {
      const val = this.currentAnalysis
      if (val === 'A1C') {
        this.find1cDetectData(queryParams)
      } else if (val === 'A2C') {
        this.find2cDetectData(queryParams)
      } else if (val === 'A3C') {
        this.find3cDetectData(queryParams)
      } else if (val === 'A4C') {
        this.find4cDetectData(queryParams)
      } else if (val === 'A5C') {
        this.find5cDetectData(queryParams)
      }
    },
    find1cDetectData(queryParams) {
      this.tableDataDefect = {}
      find1cDetectData(queryParams).then(response => {
        // console.log('1C检测数据查询', response)
        if (response.data) {
          this.tableDataDefect = response.data
        }
      })
    },
    find2cDetectData(queryParams) {
      this.tableDataDefect = {}
      find2cDetectData(queryParams).then(response => {
        // console.log('2C检测数据查询', response)
        if (response.data) {
          this.tableDataDefect = response.data
        }
      })
    },
    find3cDetectData(queryParams) {
      this.tableDataDefect = {}
      find3cDetectData(queryParams).then(response => {
        // console.log('3C检测数据查询', response)
        if (response.data) {
          this.tableDataDefect = response.data
        }
      })
    },
    find4cDetectData(queryParams) {
      this.tableDataDefect = {}
      find4cDetectData(queryParams).then(response => {
        // console.log('4C检测数据查询', response)
        if (response.data) {
          this.tableDataDefect = response.data
        }
      })
    },
    find5cDetectData(queryParams) {
      this.tableDataDefect = {}
      find5cDetectData(queryParams).then(response => {
        // console.log('5C检测数据查询', response)
        if (response.data) {
          this.tableDataDefect = response.data
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
  .datas-left {
    width: 100px;
    margin-right: 15px;
    text-align: center;

    .datas-left-p {
      margin-bottom: 20px;
      font-size: 18px;
      line-height: 30px;
    }

    .datas-left-p-qh {
      .active {
        color: #fff;
        background: #1c3369;
      }

      > li {
        height: 30px;
        margin-bottom: 20px;
        font-size: 14px;
        line-height: 30px;
        text-align: center;
        border: 1px solid #384e78;

        a {
          display: block;
        }
      }
    }
  }
</style>

<style lang="scss">
.phm-tanc {
  position: fixed;
  top: 0;
  left: 110%;
  z-index: 1002;
  width: 100%;
  height: 100%;
  overflow: auto;
  transition: all 0.4s linear;

  .phm-tanc-top {
    // margin-top: 10px;
    // margin-bottom: 10px;
    // margin-left: 15px;
    // font-size: 16px;
    // line-height: 30px;
    color: #fff;

    .el-icon-close {
      float: right;
      margin-right: 10px;
      font-size: 23px;
      cursor: pointer;
    }

    .el-icon-arrow-left {
      margin-right: 4px;
      font-size: 18px;
      cursor: pointer;
    }

    .phm-cen {
      margin-right: 10px;
      margin-left: 10px;
      font-size: 13px;
      color: #199ed8;
    }
  }

  .form-fault-tanc {
    .el-input__inner {
      background: none;
      border: 1px solid #384e78;
    }

    .el-radio {
      vertical-align: middle;
    }
  }
}

.phmtancshow {
  left: 0;

  .phm-tanc-cent {
    right: 0;
  }
}

.form-top-p {
  float: left;
  margin-right: 10px !important;
  margin-bottom: 10px;
  font-size: 14px;
  color: #fff;

  .el-input__inner {
    height: 28px;
    line-height: 28px;
  }

  .el-select {
    .el-input__icon {
      line-height: 28px;
    }
  }

  .el-date-editor {
    .el-range__icon,
    .el-range-separator,
    .el-range__close-icon {
      line-height: 20px;
    }
  }
}

.foremZank .el-table td {
  vertical-align: top;

  div {
    overflow: auto;
    text-overflow: inherit;
    white-space: inherit;
  }
}
</style>
